package com.ycw.controller.wang;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycw.bean.QuestionOther;
import com.ycw.service.wang.QuestionOtherService;
import com.ycw.util.Msg;


@Controller
public class WangwangQuestionOtherController {


	@Autowired
	QuestionOtherService questionOtherService;


	// 查询所有子问题
	@RequestMapping("/getAllQuestionOther")
	@ResponseBody
	public Msg getAllQuestionOther(@RequestParam(value="pn",defaultValue="1")Integer pn) {
		PageHelper.startPage(pn,5);
		List<QuestionOther> question = questionOtherService.getAllQuestionOther();
		PageInfo page=new PageInfo(question);
		return Msg.success().add("pageInfo",page);
	}


	// 添加子问题
	@RequestMapping("/addQuestionOther")
	@ResponseBody
	public Msg addQuestionOther(QuestionOther question) {
		SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		question.setQuestiondate(simpleDateFormat.format(new Date().getTime()));
		boolean f = questionOtherService.addQuestionOther(question);
		return Msg.success().add("question", question);
	}


	// 修改子问题
	@RequestMapping("/updateQuestionOther")
	@ResponseBody
	public Msg updateQuestionOther(QuestionOther question) {
		boolean f = questionOtherService.updateQuestionOther(question);
		return Msg.success().add("question", question);
	}


	// 删除子问题
	@RequestMapping("/deleteQuestionOther")
	@ResponseBody
	public Msg deleteQuestionOther(QuestionOther question) {
		boolean f = questionOtherService.deleteQuestionOther(question);
		return Msg.success().add("question", question);
	}
	
	//查询一个问题
	@RequestMapping("/getNewsById")
	@ResponseBody
	public Msg getNewsById(QuestionOther question) {
		
		question=questionOtherService.getNewsById(question);
		return Msg.success().add("question", question);
	}
}
